<!doctype html>
<html lang="zh-CN">
<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>【补交】作业8 | 邵吹水的博客</title>
    <meta property="og:title" content="【补交】作业8 - 邵吹水的博客">
    <meta property="og:type" content="article">
        
    <meta property="article:published_time" content='2021-01-05T16:34:11&#43;08:00'>
        
        
    <meta property="article:modified_time" content='2021-01-05T16:34:11&#43;08:00'>
        
    <meta name="Keywords" content="中山大学,shaozhd,吹水,软件工程,C语言,Wikipedia,博客">
    <meta name="description" content="【补交】作业8">
        
    <meta name="author" content="shaozhd">
    <meta property="og:url" content="https://shaozhd.gitee.io/post/wiki8/">
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">

    <link rel="stylesheet" href='/css/normalize.css'>
    <link rel="stylesheet" href='/css/style.css'>
    <script type="text/javascript" src="//cdn.bootcdn.net/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

    
    
    
    
    
    
        <link rel="stylesheet" href='/css/douban.css'>
    
        <link rel="stylesheet" href='/css/other.css'>
    
</head>


<body>
    <header id="header" class="clearfix">
    <div class="container">
        <div class="col-group">
            <div class="site-name ">
                
                    <a id="logo" href="https://shaozhd.gitee.io">
                        邵吹水的博客
                    </a>
                
                <p class="description">一点儿都不想做学渣的软工本科小邵同学</p>
            </div>
            <div>
                <nav id="nav-menu" class="clearfix">
                    <a class="current" href="https://shaozhd.gitee.io">首页</a>
                    
                    <a  href="https://shaozhd.gitee.io/homework/" title="作业">作业</a>
                    
                    <a  href="https://shaozhd.gitee.io/archives/" title="归档">归档</a>
                    
                    <a  href="https://shaozhd.gitee.io/about/" title="关于">关于</a>
                    
                </nav>
            </div>
        </div>
    </div>
</header>

    <div id="body">
        <div class="container">
            <div class="col-group">

                <div class="col-8" id="main">
                    
<div class="res-cons">
    <style type="text/css">
    .post-toc {
        position: fixed;
        width: 200px;
        margin-left: -210px;
        padding: 5px 10px;
        font-family: Athelas, STHeiti, Microsoft Yahei, serif;
        font-size: 12px;
        border: 1px solid rgba(0, 0, 0, .07);
        border-radius: 5px;
        background-color: rgba(255, 255, 255, 0.98);
        background-clip: padding-box;
        -webkit-box-shadow: 1px 1px 2px rgba(0, 0, 0, .125);
        box-shadow: 1px 1px 2px rgba(0, 0, 0, .125);
        word-wrap: break-word;
        white-space: nowrap;
        -webkit-box-sizing: border-box;
        box-sizing: border-box;
        z-index: 999;
        cursor: pointer;
        max-height: 70%;
        overflow-y: auto;
        overflow-x: hidden;
    }

    .post-toc .post-toc-title {
        width: 100%;
        margin: 0 auto;
        font-size: 20px;
        font-weight: 400;
        text-transform: uppercase;
        text-align: center;
    }

    .post-toc .post-toc-content {
        font-size: 15px;
    }

    .post-toc .post-toc-content>nav>ul {
        margin: 10px 0;
    }

    .post-toc .post-toc-content ul {
        padding-left: 20px;
        list-style: square;
        margin: 0.5em;
        line-height: 1.8em;
    }

    .post-toc .post-toc-content ul ul {
        padding-left: 15px;
        display: none;
    }

    @media print,
    screen and (max-width:1057px) {
        .post-toc {
            display: none;
        }
    }
</style>
<div class="post-toc" style="position: absolute; top: 188px;">
    <h2 class="post-toc-title">文章目录</h2>
    <div class="post-toc-content">
        <nav id="TableOfContents"></nav>
    </div>
</div>
<script type="text/javascript">
    $(document).ready(function () {
        var postToc = $(".post-toc");
        if (postToc.length) {
            var leftPos = $("#main").offset().left;
            if(leftPos<220){
                postToc.css({"width":leftPos-10,"margin-left":(0-leftPos)})
            }

            var t = postToc.offset().top - 20,
                a = {
                    start: {
                        position: "absolute",
                        top: t
                    },
                    process: {
                        position: "fixed",
                        top: 20
                    },
                };
            $(window).scroll(function () {
                var e = $(window).scrollTop();
                e < t ? postToc.css(a.start) : postToc.css(a.process)
            })
        }
    })
</script>
    <article class="post">
        <header>
            <h1 class="post-title">【补交】作业8</h1>
        </header>
        <date class="post-meta meta-date">
            2021年1月5日
        </date>
        
        
        <div class="post-meta">
            <span id="busuanzi_container_page_pv">|<span id="busuanzi_value_page_pv"></span><span>
                    阅读</span></span>
        </div>
        
        
        <div class="post-content">
            <h1 id="一阅读伪代码标准">一、阅读伪代码标准</h1>
<ol>
<li>用伪代码描述将十进制转换为十六进制的方法</li>
</ol>
<pre><code>SET FUNCTION TURN(num)
    now = num % 16
    IF num / 16 != 0 THEN
    TURN(num / 16)
    ENDIF
    CASE now OF
        0 : PRINT &quot;0&quot;
        1 : PRINT &quot;1&quot;
        2 : PRINT &quot;2&quot;
        3 : PRINT &quot;3&quot;
        4 : PRINT &quot;4&quot;
        5 : PRINT &quot;5&quot;
        6 : PRINT &quot;6&quot;
        7 : PRINT &quot;7&quot;
        8 : PRINT &quot;8&quot;
        9 : PRINT &quot;9&quot;
        10 : PRINT &quot;A&quot;
        11 : PRINT &quot;B&quot;
        12 : PRINT &quot;C&quot;
        13 : PRINT &quot;D&quot;
        14 : PRINT &quot;E&quot;
        15 : PRINT &quot;F&quot;
    ENDCASE
ENDFUCTION

READ number
IF number &lt; 0 THEN
    PRINT &quot;-&quot;
    number = -number;
ENDIF
TURN(number)
</code></pre><ol start="2">
<li>C语言实现</li>
</ol>
<pre><code>#include &lt;stdio.h&gt;
void A (int num)
{
    int a;
    a = num % 16;
    if ( num &gt;= 16 ) {
        A(num / 16);
    }
    switch ( a ) {
        case 10:
            printf(&quot;A&quot;);
            break;
        case 11:
            printf(&quot;B&quot;);
            break;
        case 12:
            printf(&quot;C&quot;);
            break;
        case 13:
            printf(&quot;D&quot;);
            break;
        case 14:
            printf(&quot;E&quot;);
            break;
        case 15:
            printf(&quot;F&quot;);
            break;
        default:
            printf(&quot;%d&quot;, a);
    }
}
int main (void)
{
    int num;
    scanf(&quot;%d&quot;, &amp;num);
    A(num);
    return 0;
}
</code></pre><ol start="3">
<li>程序测试</li>
</ol>
<table>
<thead>
<tr>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td>-1</td>
<td>-1</td>
</tr>
<tr>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td>1</td>
<td>1</td>
</tr>
<tr>
<td>15</td>
<td>F</td>
</tr>
<tr>
<td>26</td>
<td>1A</td>
</tr>
<tr>
<td>3625</td>
<td>E29</td>
</tr>
</tbody>
</table>
<h1 id="二名词解释">二、名词解释</h1>
<ol>
<li>
<p>自上而下的设计 自上而下的方法（也称为逐步设计，在某些情况下用作分解的代名词）实质上是对系统进行分解，以反向工程的方式深入了解其组成子系统。</p>
</li>
<li>
<p>工作分解结构（WBS） 在项目管理和系统工程中，工作分解结构（WBS）是将项目的交付导向型分解为较小的组件。</p>
</li>
<li>
<p>简述管理学WBS与信息学Top-down设计的异同 同：分解一个系统以了解其组成子系统异：Top-down由上到下，WBS根据不同类别分为小的部分</p>
</li>
</ol>
<h1 id="三仔细观察您的洗衣机的运转过程从上到下的设计方法和伪代码描述洗衣机控制程序">三、仔细观察您的洗衣机的运转过程，从上到下的设计方法和伪代码描述洗衣机控制程序</h1>
<p>假设洗衣机一体机的基本操作如下：</p>
<pre><code>water_in_switch（open_close）//打开：上水开关，close关闭water_out_switch

（open_close）//打开：排水开关，close关闭

get_water_volume（）//返回洗衣机内部水的高度

motor_run（direction）//电机转动。left左转，right右转，stop停

time_counter（）//返回当前时间计数，以秒为单位halt（returncode）//插入，成功成功failure失败
</code></pre><ol>
<li>请使用伪代码分解“正常洗衣”程序的大步骤。包括注水，浸泡等</li>
</ol>
<pre><code>选择 洗衣模式 输入 水位、时间
注水至预定水位
浸泡预定时间
漂洗预定时间
    每个周期 电机转 左三秒 右三秒
排水至水位为0
脱水
    电机快速转 每个周期 左100秒 右100秒 5周期
关闭电源
</code></pre><ol start="2">
<li>进一步用基本操作，控制语句（IF，FOR，WHILE等），变量与表达式，写出每个步骤的伪代码</li>
</ol>
<pre><code>READ(water_line, soak_time, rinse_time)

WHILE getwatervolume() &lt; water_line
    waterinwitch(open)
ENDWHILE

waterinswitch(close)

SET now = timecounter()
WHILE timecounter() &lt;= now + soak_time
    SET now1 = timecounter()
    motorrun(left)
    IF timecounter() == now1 + 3
        motorrun(right)
    ENDIF
    IF timecounter() == now1 + 6
        motorrun(stop)
    ENDIF
ENDWHILE

WHILE getwatervolume() &gt; 0
    wateroutswitch(open)
ENDWHILE

FOR i = 1 to 5
    now1 = timecounter();
    motorrun(left)
    IF timecounter() == now1 + 100
        motorrun(right)
    ENDIF
    IF timecounter() == now1 + 200
        motorrun(stop)
    ENDIF
ENDFOR
wateroutswitch(close)
halt(success)
</code></pre><ol start="3">
<li>
<p>根据你的实践，请分析“正常洗衣”与“快速洗衣”在用户目标和程序上的异同。你认为存在改进（创新）空间，简单说明你的改进意见？ 答：快速洗衣不需要浸泡</p>
</li>
<li>
<p>通过步骤3，提取一些共性功能模块（函数），简化“正常洗衣”程序，使程序变得更利于人类理解和修改维护。例如：wait（time）//等待指定的时间；注水（ volume，timeout）//在指定时间内完成注水，否则中断；排水（timeout）。等子程序</p>
</li>
</ol>
<pre><code>FUNCTION wait(time)
    SET now = timecounter();
    WHILE timecounter() &lt;= now + soak_time
    ENDWHILE
ENDFUNCTION

FUNCTION pipein(volume, timeout)
    SET now = timecounter();
    WHILE getwatervolume() &lt; volume
        waterinswitch(open)
        IF timecounter() now + timeout
            halt(failure)
            BREAK
        ENDIF
    ENDWHILE
    waterinswitch(close)
ENDFUNCTION

FUNCTION pipeout(timeout)
    SET now timecounter();
    WHILE getwatervolume() &gt; 0
        wateroutswitch(open)
        IF timecounter() now + timeout
            halt(failure)
            BREAK
        ENDIF
    ENDWHILE
ENDFUNCTION
</code></pre>
        </div>

        
<div class="post-archive">
    <ul class="post-copyright">
        <li><strong>原文作者：</strong><a rel="author" href="https://shaozhd.gitee.io">shaozhd</a></li>
        <li style="word-break:break-all"><strong>原文链接：</strong><a href="https://shaozhd.gitee.io/post/wiki8/">https://shaozhd.gitee.io/post/wiki8/</a></li>
        <li><strong>版权声明：</strong>本作品采用<a rel="license" href="https://zh.wikipedia.org/wiki/%e5%85%b1%e4%ba%a7%e4%b8%bb%e4%b9%89">我自己看一遍的方法</a>进行许可，非商业转载请注明出处（作者，原文链接），商业转载请联系作者获得授权。</li>
    </ul>
</div>
<br/>



        

<div class="post-archive">
    <h2>See Also</h2>
    <ul class="listing">
        
        <li><a href="/post/wiki10/">【补交】作业10</a></li>
        
        <li><a href="/post/wiki9/">【补交】作业9</a></li>
        
        <li><a href="/post/project4/">【补交】项目4</a></li>
        
        <li><a href="/post/project5/">【补交】项目5</a></li>
        
        <li><a href="/post/project6/">【补交】项目6</a></li>
        
    </ul>
</div>


        <div class="post-meta meta-tags">
            
            没有标签
            
        </div>
    </article>
    
    <div id="disqus_thread"></div>
<script type="application/javascript">
    var disqus_config = function () {
    
    
    
    };
    (function() {
        if (["localhost", "127.0.0.1"].indexOf(window.location.hostname) != -1) {
            document.getElementById('disqus_thread').innerHTML = 'Disqus comments not available by default when the website is previewed locally.';
            return;
        }
        var d = document, s = d.createElement('script'); s.async = true;
        s.src = '//' + "yourdiscussshortname" + '.disqus.com/embed.js';
        s.setAttribute('data-timestamp', +new Date());
        (d.head || d.body).appendChild(s);
    })();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="https://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>

    
    
</div>

                    <footer id="footer">
    <div>
        &copy; 2021 <a href="https://shaozhd.gitee.io">邵吹水的博客 By shaozhd</a>
        
    </div>
    <br />
    <div>
        <div class="github-badge">
            <a href="https://gohugo.io/" target="_black" rel="nofollow"><span class="badge-subject">Powered by</span><span class="badge-value bg-blue">Hugo</span></a>
        </div>
        <div class="github-badge">
            <a href="https://www.flysnow.org/" target="_black"><span class="badge-subject">Design by</span><span class="badge-value bg-brightgreen">飞雪无情</span></a>
        </div>
        <div class="github-badge">
            <a href="https://github.com/flysnow-org/maupassant-hugo" target="_black"><span class="badge-subject">Theme</span><span class="badge-value bg-yellowgreen">Maupassant</span></a>
        </div>
    </div>
</footer>


    
    <script type="text/javascript">
        window.MathJax = {
            tex2jax: {
                inlineMath: [['$', '$']],
                processEscapes: true
                }
            };
    </script>
    <script src='https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML' async></script>

<a id="rocket" href="#top"></a>
<script type="text/javascript" src='/js/totop.js?v=0.0.0' async=""></script>



    <script type="text/javascript" src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js" async></script>




    <script src='/js/douban.js'></script>


                </div>

                <div id="secondary">
    <section class="widget">
        <form id="search" action='https://shaozhd.gitee.io/search/' method="get" accept-charset="utf-8" target="_blank" _lpchecked="1">
      
      <input type="text" name="q" maxlength="20" placeholder="Search">
      <input type="hidden" name="sitesearch" value="https://shaozhd.gitee.io">
      <button type="submit" class="submit icon-search"></button>
</form>
    </section>
    
    <section class="widget">
        <h3 class="widget-title">最近文章</h3>
<ul class="widget-list">
    
    <li>
        <a href="https://shaozhd.gitee.io/post/wiki10/" title="【补交】作业10">【补交】作业10</a>
    </li>
    
    <li>
        <a href="https://shaozhd.gitee.io/post/wiki8/" title="【补交】作业8">【补交】作业8</a>
    </li>
    
    <li>
        <a href="https://shaozhd.gitee.io/post/wiki9/" title="【补交】作业9">【补交】作业9</a>
    </li>
    
    <li>
        <a href="https://shaozhd.gitee.io/post/project4/" title="【补交】项目4">【补交】项目4</a>
    </li>
    
    <li>
        <a href="https://shaozhd.gitee.io/post/project5/" title="【补交】项目5">【补交】项目5</a>
    </li>
    
    <li>
        <a href="https://shaozhd.gitee.io/post/project6/" title="【补交】项目6">【补交】项目6</a>
    </li>
    
    <li>
        <a href="https://shaozhd.gitee.io/post/project7/" title="【补交】项目7">【补交】项目7</a>
    </li>
    
    <li>
        <a href="https://shaozhd.gitee.io/post/project9/" title="项目9：字符游戏-智能蛇">项目9：字符游戏-智能蛇</a>
    </li>
    
    <li>
        <a href="https://shaozhd.gitee.io/post/project8/" title="项目8：字符游戏-贪吃蛇">项目8：字符游戏-贪吃蛇</a>
    </li>
    
    <li>
        <a href="https://shaozhd.gitee.io/post/wiki7/" title="使用维基百科(Wikipedia)解释名词VII及其解答题">使用维基百科(Wikipedia)解释名词VII及其解答题</a>
    </li>
    
</ul>
    </section>

    

    <section class="widget">
        <h3 class="widget-title"><a href="/categories">分类</a></h3>
<ul class="widget-list">
    
</ul>
    </section>

    <section class="widget">
        <h3 class="widget-title"><a href="/tags">标签</a></h3>
<div class="tagcloud">
    
</div>
    </section>

    

    <section class="widget">
        <h3 class="widget-title">其它</h3>
        <ul class="widget-list">
            <li><a href="https://shaozhd.gitee.io/index.xml">文章 RSS</a></li>
        </ul>
    </section>
</div>
            </div>
        </div>
    </div>
</body>

</html>